from die import Die
import pygal

# 构建掷骰子点数的数列

# 创建一个骰子的实例
die = Die()
# 数字列表
results = []
for roll_num in range(1000):
    results.append(die.roll())

# 分析每个点数出现的次数
frequencies = []
for value in range(1,7):
    frequency = results.count(value)
    frequencies.append(frequency)

# 使用pygal.Bar()方法绘制直方图
hist = pygal.Bar()

hist.title = "Results of rolling one D6 1000 times."
hist.x_labels = ['1','2','3','4','5','6']
hist.x_title = "Result"
hist.y_title = "Frequencies of Result."

# add()方法添加系列值，'D6'指定系列名
hist.add('D6', frequencies)
hist.render_to_file('die_visual.svg')